package Servlet.User;

import DataBase.DataBase;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 检测ID有无重复服务器端
 */
@WebServlet("/FindRegister")
public class FindRegisterServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取前端传入的数据
        String username = req.getParameter("username");
        boolean haveRegister = DataBase.HaveRegister(username);
        resp.setCharacterEncoding("UTF-8");
        if(haveRegister) resp.getWriter().write("该ID已被注册！");
        else resp.getWriter().write("该ID尚未被注册！");
    }


    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doGet(request, response);
    }

}